/*************************************
 * Joe Helgeson
 * CS362 Assignment 3
 * Unit tests for various 
 * non-card-specific functions
 *
 * unittest4.c test for handCard()
 ************************************/

#include "dominion.h"
#include "dominion_helpers.h"
#include "rngs.h"
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <assert.h>
#include <time.h>

//enabling debugging messages to appear
//#ifdef DEBUG
//#undef DEBUG
//#endif
//#define DEBUG 1

void testIt(struct gameState* tState);

///////////////////////////////////////
int main(int argc, char const** argv) {
	struct gameState* tState = malloc(sizeof(struct gameState));
	srand(time(NULL));	//init random seed
	testIt(tState);
	free(tState);
	return 0;
}

///////////////////////////////////////
void testIt(struct gameState* tState) {

	int t; 	//test number
	for(t=0; t<50; t++) {
		//setup
		int rPlyr = rand() % 4; 	//pick a random player
		tState->whoseTurn = rPlyr;	//make it that player's turn
		int rCard = rand() % 27;	//pick a random card from the set
		int rHPos = rand() % 15;	//pick a random position in hand
		tState->hand[rPlyr][rHPos] = rCard; //set card at that hand position
	
		//compare output of handCard()
		int res = handCard(rHPos, tState);
		if(res == rCard) {
			printf("Hand card (%d) matches expected value (%d), test passed for Player #%d.\n", res, rCard, rPlyr);
		}
		else {
			printf("Hand card (%d) doesn't match expected value (%d), test failed for Player #%d.\n", res, rCard, rPlyr);
		}
	}
	printf("Unit test for handCard() passed.\n");
	return;
}

